package com.example.tenant.controller;

import com.example.tenant.service.tenant.TenantService;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequiredArgsConstructor
@RequestMapping("/tenant")
public class TenantController {


    private final TenantService tenantService;

    @Value("${excel-export-path:}")
    private String filePath;

    @Value("${tenant-id:}")
    private Long tenantId;

    @SneakyThrows
    @GetMapping("/import")
    public void imp() {
        tenantService.imp(filePath);
    }

    @SneakyThrows
    @GetMapping("/export")
    public void export() {
        // 将生成的SQL内容写入响应输出流
        tenantService.export(tenantId, filePath);
    }
}
